package com.gxa.service.asset.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.asset.ConnectRecord;
import com.gxa.entity.asset.Equipment;
import com.gxa.entity.asset.search.ConnectRecordSearchMap;
import com.gxa.service.asset.ConnectRecordService;
import com.gxa.mapper.asset.ConnectRecordMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
* @author Administrator
* @description 针对表【t_connect_record(移交申请记录表)】的数据库操作Service实现
* @createDate 2022-10-14 08:22:14
*/
@Service
public class ConnectRecordServiceImpl extends ServiceImpl<ConnectRecordMapper, ConnectRecord>
    implements ConnectRecordService{
    @Autowired
    private ConnectRecordMapper mapper;

    @Override
    public PageInfo<ConnectRecord> queryByPage(ConnectRecordSearchMap map) {
        PageHelper.startPage(map.getPageNum(),map.getPageSize());//1.开启分页

        QueryWrapper<ConnectRecord> wrapper = new QueryWrapper<>();//2.条件构造器 模拟写动态sql  或者在xml 中写
        if (!StringUtils.isBlank(map.getApplyId())) {
            wrapper.like("connect_apply_num", map.getApplyId());
        }
        if(!StringUtils.isBlank(map.getApplyPerson())){
            wrapper.like("apply_person",map.getApplyPerson());
        }
        if(!StringUtils.isBlank(map.getDept())){
            wrapper.like("connect_apply_dep",map.getDept());
        }
        if(!StringUtils.isAnyBlank(map.getStartTime(),map.getEndTime())){
            wrapper.between("application_time",map.getStartTime(),map.getEndTime());
        }
        PageInfo<ConnectRecord> pageInfo = new PageInfo<>(mapper.selectList(wrapper));//3.获取分页信息
        return pageInfo;
    }

    @Override
    public Set<String> getDepts() {
        return mapper.getDepts();
    }
}




